<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>本地网页</title>
		<link href="../../static/css/lizhao.min.css" rel="stylesheet" />
		<link href="../../static/iconfont/iconfont.css" rel="stylesheet" type="text/css" />
		<link href="css/local.css" rel="stylesheet" type="text/css" />
		<script src="../../static/js/lizhao.min.js"></script>
		<!-- <script src="js/stickybits.min.js"></script> -->

		<style>
			/* .stickybits-title.js-is-sticky {
			  top: 0;
			}
			.stickybits-title.js-is-stuck {
			  bottom: 0;
			} */
		</style>
	</head>
	<body class="div0">
		<div class="status_bar"></div>

		<div class="lizhao-video">
			<div class="lizhao-video-top">
				<p class="mui-icon mui-icon-back" onclick="back()"></p>
				<p class="video-top-right">广告</p>
			</div>
			<div class="video-html"></div>
		</div>
		<div class="center">
			<div class="stickybits-title">
				<p class="t-left"></p>
				<p class="mui-icon mui-icon-closeempty"></p>
			</div>
			<iframe id="lizhaoHtml" style="display: block;width:100%;height: 100%;" frameborder="0" scrolling="no" seamless="seamless"
			 src=""></iframe>
			<!-- <div class="center-img-warp">
			</div> -->

		</div>

		<!-- uni 的 SDK -->
		<script type="text/javascript" src="../../static/js/uniapp.js"></script>
		<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
		<script type="text/javascript">
			window.onscroll = function() {
				//变量scrollTop是滚动条滚动时，距离顶部的距离
				var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
				//变量windowHeight是可视区的高度
				var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
				//变量scrollHeight是滚动条的总高度
				var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
				//滚动条到底部的条件
				if (scrollTop + windowHeight == scrollHeight||scrollTop + windowHeight>scrollHeight) {
					$('#lizhaoHtml').attr({scrolling:"yes"})
					$('#lizhaoHtml').attr("src", $('#lizhaoHtml').attr("src"));//jQuery设置.attr为scrolling="yes"并重新加载iframe！否则无效
				}
				//滚动到最上层
				if(scrollTop==0||scrollTop<0){
					$('#lizhaoHtml').attr({scrolling:"no"})
					$('#lizhaoHtml').attr("src", $('#lizhaoHtml').attr("src"));//jQuery设置.attr为scrolling="yes"并重新加载iframe！否则无效
				}
			}
			mui.init({
				keyEventBind: {
					backbutton: false //关闭back按键监听
				}
			});
			document.addEventListener('UniAppJSBridgeReady', function() {
				//获取系统状态栏高度
				let StatusbarHeight = plus.navigator.getStatusbarHeight();
				console.log(StatusbarHeight);
				$('.status_bar').css({
					height: StatusbarHeight
				})
				$('.lizhao-video').css({
					top: StatusbarHeight
				})
				$('.center .title').css({
					top: StatusbarHeight
				})
				// uni.postMessage({
				// 	data: {
				// 		action: 'message'
				// 	}
				// });

			});
			try {
				let pageData = JSON.parse(getQuery('data'))
				//页面赋值
				assignment()

				function assignment() {
					$('.center .stickybits-title .t-left').html(pageData.imageInfo)
					let videoHtml =
						`<video id="video" controls="controls" autoplay poster="${pageData.src}" preload="preload" src="${pageData.account.video}"></video>`
					$('.video-html').html(videoHtml) //视频封面
					//广告详情
					$('#lizhaoHtml').attr("src", pageData.account.htmlUrl);
				}
				//获取 uni-app 传来的值
				//取url中的参数值
				function getQuery(name) {
					// 正则：[找寻'&' + 'url参数名字' = '值' + '&']（'&'可以不存在）
					let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
					let r = window.location.search.substr(1).match(reg);
					if (r != null) {
						// 对参数值进行解码
						return decodeURIComponent(r[2]);
					}
					return null;
				}
			} catch (e) {
				//TODO handle the exception
				setTimeout(() => {
					uni.navigateBack({
						delta: 1,
					});
				}, 100)
			}



			function back() {
				uni.navigateBack({
					delta: 1,
				});
			}
		</script>
	</body>
</html>
